package com.djx.plus.controller;

import com.djx.comm.controller.BaseController;
import com.djx.plus.entity.Book;
import com.djx.plus.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author PACTERA-468
 */
@RestController
@RequestMapping("book/")
public class BookController extends BaseController {

    @Autowired
    BookService bookService;

    @GetMapping("queryById")
    public Object queryById(String id) throws Exception {
        return successObject(bookService.queryById(id));
    }

    @GetMapping("queryList")
    public Object queryList(Book book) throws Exception {
        return successObject(bookService.queryList(book));
    }

    @GetMapping("insert")
    public Object insert(Book book) throws Exception {
        Integer num = bookService.insert(book);
        if (num > 0) {
            return successMsg("添加成功");
        }
        return successMsg("添加失败");
    }

    @GetMapping("queryPage")
    public Object queryPage(Book book, int start, int end) {
        return successObject(bookService.queryPage(book, start, end));
    }


}
